package jmine.tec.services.utils.replace.transformation;

import java.util.Map;

import jmine.tec.services.utils.replace.api.ServiceRow;

public class MapAndConditionedReplaceContentTransformation extends AbstractMapReplaceContentTransformation {

    private final Map<String, String> conditionMap;

    public MapAndConditionedReplaceContentTransformation(String action, String name, String parameter, Map<String, String> conditionMap,
            Map<String, String> replacementMap) {
        super(action, name, parameter, replacementMap);
        this.conditionMap = conditionMap;
    }

    @Override
    protected boolean acceptServiceRow(ServiceRow row) {
        for (String parameterName : this.conditionMap.keySet()) {
            if (!row.getStringParameter(parameterName).equals(this.conditionMap.get(parameterName))) {
                return false;
            }
        }
        return true;
    }

}
